package kr.pe.johnkim.carrotpoint.mobile.service;

import kr.pe.johnkim.carrotpoint.mobile.dao.CarrotPointAgencyDao;
import kr.pe.johnkim.carrotpoint.mobile.domain.CarrotPointAgency;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Carrot Point 대리점 관련 service 클래스 이다.
 *
 * @author : John_Kim <cale9797@gmail.com>
 * @date : 13. 2. 6.
 */
@Service
public class CarrotPointAgencyServiceImpl implements CarrotPointAgencyService {

    // SLF4J Logging
    private Logger logger = LoggerFactory.getLogger(CarrotPointAgencyServiceImpl.class);

    @Autowired
    private CarrotPointAgencyDao carrotPointAgencyDao;

    /**
     * 대리점 코드로 중복 검사를 한다.
     *
     * @param carrotPointAgency
     * @return
     */
    @Override
    public CarrotPointAgency getAgencyCodeExistByCode(CarrotPointAgency carrotPointAgency) {
        logger.info("getAgencyCodeExistByCode");
        return carrotPointAgencyDao.getAgencyCodeExistByCode(carrotPointAgency);
    }

    /**
     * 대리점 코드를 등록 한다.
     *
     * @param carrotPointAgency
     */
    @Override
    public void registerAgencyCode(CarrotPointAgency carrotPointAgency) {
        logger.info("registerAgencyCode");
        carrotPointAgencyDao.registerAgencyCode(carrotPointAgency);
    }

    /**
     * 대리점 코드 목록을 가져 온다.
     *
     * @param carrotPointAgency
     * @return
     */
    @Override
    public List<CarrotPointAgency> getAgencyCodeList(CarrotPointAgency carrotPointAgency) {
        logger.info("getAgencyCodeList");
        return carrotPointAgencyDao.getAgencyCodeList(carrotPointAgency);
    }

    /**
     * 대리점 코드 내용을 수정 한다.
     *
     * @param carrotPointAgency
     */
    @Override
    public void updateAgencyCode(CarrotPointAgency carrotPointAgency) {
        logger.info("updateAgencyCode");
        carrotPointAgencyDao.updateAgencyCode(carrotPointAgency);
    }

    /**
     * 대리점 코드 활성화 여부를 업데이트 한다.
     *
     * @param carrotPointAgency
     */
    @Override
    public void updateAgencyCodeActivateYn(CarrotPointAgency carrotPointAgency) {
        logger.info("updateAgencyCodeActivateYn");
        carrotPointAgencyDao.updateAgencyCodeActivateYn(carrotPointAgency);
    }
}
